package com.it.data_tree.util;

public class ColorPrintln {
    /**
     * 自定义颜色
     *
     * @param origin
     * @param color
     */
    public static void colorPrintln (Object origin, int color) {
        System.out.printf("\033[%dm%s\033[0m%n", color, origin);
    }
    
    /**
     * 黑色
     *
     * @param origin
     */
    public static void blackPrintln (Object origin) {
        colorPrintln(origin, 30);
    }
    
    /**
     * 红色
     *
     * @param origin
     */
    public static void redPrintln (Object origin) {
        colorPrintln(origin, 91);
    }
    
    /**
     * 绿色
     *
     * @param origin
     */
    public static void greenPrintln (Object origin) {
        colorPrintln(origin, 92);
    }
    
    /**
     * 黄色
     *
     * @param origin
     */
    public static void yellowPrintln (Object origin) {
        colorPrintln(origin, 93);
    }
    
    /**
     * 蓝色
     *
     * @param origin
     */
    public static void bluePrintln (Object origin) {
        colorPrintln(origin, 94);
    }
    
    /**
     * 粉色
     *
     * @param origin
     */
    public static void pinkPrintln (Object origin) {
        colorPrintln(origin, 95);
    }
    
    /**
     * 白色背景
     *
     * @param origin
     */
    public static void whiteBgColorPrintln (Object origin) {
        colorPrintln(origin, 7);
    }
    
    /**
     * 青色
     *
     * @param origin
     */
    public static void cyanPrintln (Object origin) {
        colorPrintln(origin, 96);
    }
    
    /**
     * 黑色背景
     *
     * @param origin
     */
    public static void blackBgColorPrintln (Object origin) {
        colorPrintln(origin, 40);
    }
    
    /**
     * 灰色背景
     *
     * @param origin
     */
    public static void grayBgColorPrintln (Object origin) {
        colorPrintln(origin, 100);
    }
    
    /**
     * 红色背景
     *
     * @param origin
     */
    public static void redBgColorPrintln (Object origin) {
        colorPrintln(origin, 101);
    }
    
    /**
     * 绿色背景
     *
     * @param origin
     */
    public static void greenBgColorPrintln (Object origin) {
        colorPrintln(origin, 102);
    }
    
    /**
     * 蓝色背景
     *
     * @param origin
     */
    public static void blueBgColorPrintln (Object origin) {
        colorPrintln(origin, 104);
    }
    
    /**
     * 粉色背景
     *
     * @param origin
     */
    public static void pinkBgColorPrintln (Object origin) {
        colorPrintln(origin, 105);
    }
    
    public static void getAllColor () {
        for (int i = 0; i <= 110; i++) {
            if (i % 2 == 0) {
                colorPrintln(i + " 是偶数", i);
            } else {
                colorPrintln(i + " 是奇数", i);
            }
        }
    }
}